<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no" />
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css"/>
    <style>
        html, body {
            background-color: #f8f8f8;
        }
        .evaluate_main {
            height: 75px;
            background-color: #fff;
            border-bottom: 1px solid #e8e8e8;
            display: -webkit-box;
            -webkit-box-align: center;
        }
        .evaluate_div {
            width: 100%;
            display: -webkit-box;
            display: -webkit-flex;
        }
        .evaluate_div .evaluate_divl {
            width: 125px;
            box-sizing: border-box;
            border-right: 1px solid #999;
            text-align: center;
        }
        .evaluate_div .evaluate_divl .evaluate_p1 {
            font-size: 18px;
            color: #ffa60c;
            margin-bottom: 10px;
        }
        .evaluate_div .evaluate_divl .evaluate_p2 {
            font-size: 15px;
            color: #333;
        }
        .evaluate_div .evaluate_divr {
            flex: 1;
            -webkit-flex: 1;
            box-flex: 1;
            -webkit-box-flex: 1;
        }
        .evaluate_num_box {
            font-size: 12px;
            margin-bottom: 12px;
            color: #999;
            display: -webkit-box;
            -webkit-box-align: center;
            -webkit-box-pack: center;
        }
        .evaluate_num_box:last-child {
            margin-bottom: 0;
        }
        .evaluate_num_box .evaluate {
            display: -webkit-box;
            display: -webkit-flex;
            align-items: center;
            margin-left: 20px;
        }
        .evaluate_num_box .evaluate .evaluate_img {
            overflow: hidden;
            margin-right: 7px;
        }
        .evaluate_num_box .evaluate .evaluate_img img {
            width: 10px;
            float: left;
            margin-right: 4px;
        }
        .evaluate_num_box .evaluate .evaluate_img img:last-child {
            margin-right: 0;
        }
        .evaluate_num_box .evaluate .evaluate_num {
            font-size: 15px;
            color: #ffb33c;
        }
        .tag_box {
            background-color: #fff;
            padding: 0 13px;
            margin-bottom: 6px;
        }
        .tag_box .tag_title {
            height: 43px;
            line-height: 46px;
            color: #333;
            font-size: 15px;
        }
        .tag_box .tag_main {
            padding-bottom: 5px;
        }
        .tag_box .tag_main ul {
            overflow: hidden;
        }
        .tag_box .tag_main ul li {
            width: 23.5%;
            float: left;
            margin-right: 2%;
            margin-bottom: 10px;
        }
        .tag_box .tag_main ul li:nth-child(4n) {
            margin-right: 0;
        }
        .tag_box .tag_main ul li .li_box {
            width: 100%;
            height: 25px;
            line-height: 25px;
            font-size: 12px;
            text-align: center;
            color: #333;
            background-color: #ffedf0;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }
        .evaluate_box {
            background-color: #fff;
        }
        .evaluate_box ul li .li_box {
            display: -webkit-box;
            display: -webkit-flex;
            padding: 15px;
            border-bottom: 1px solid #e8e8e8;
        }
        .evaluate_box ul li .li_box .li_boxl .li_img {
            width: 43px;
            height: 43px;
            border-radius: 50%;
            overflow: hidden;
        }
        .evaluate_box ul li .li_box .li_boxl .li_img img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        .evaluate_box ul li .li_box .li_boxr {
            flex: 1;
            -webkit-flex: 1;
            box-flex: 1;
            -webkit-box-flex: 1;
            padding-left: 6px;
        }
        .evaluate_box ul li .li_box .li_boxr .name {
            font-size: 14px;
            color: #333;
            margin-bottom: 8px;
        }
        .evaluate_box ul li .li_box .li_boxr .evaluate {
            font-size: 12px;
            color: #999;
            display: -webkit-box;
            -webkit-box-align: center;
            margin-bottom: 15px;
        }
        .evaluate_box ul li .li_box .li_boxr .evaluate .evaluate_good {
            color: #ffa82c;
            display: block;
        }
        .evaluate_box ul li .li_box .li_boxr .evaluate .evaluate_bad {
            color: #999;
            display: block;
        }
        .evaluate_box ul li .li_box .li_boxr .evaluate img {
            height: 12px;
            margin-left: 3px;
            display: block;
        }
        .evaluate_box ul li .li_box .li_boxr .evaluate_content {
            font-size: 14px;
            color: #333;
        }
        .evaluate_box .goods_img_box {
            overflow: hidden;
            margin-top: 18px;
        }
        .evaluate_box .goods_img_box .goods_img {
            width: 60px;
            height: 60px;
            float: left;
            margin-right: 7px;
        }
        .evaluate_box .goods_img_box .goods_img img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        .loading{
            color: #ccc;
            text-align: center;
            line-height: 25px;
            display: none;
        }
        .without_data{
            display: none;
            color:#ccc;
            text-align:center;
            padding-top: 15px;
        }
        .hidden_img {
            display: none;
        }
    </style>
</head>
<body>
    <div class="evaluate_main">
        <div class="evaluate_div">
            <div class="evaluate_divl">
                <div class="evaluate_p1 score"></div>
                <div class="evaluate_p2">综合评分</div>
            </div>
            <div class="evaluate_divr">
                <div class="evaluate_num_box">
                    服务态度
                    <div class="evaluate">
                        <div class="evaluate_img service_star">
                           
                        </div>
                        <div class="evaluate_num service_score"></div>
                    </div>
                </div>
                <div class="evaluate_num_box">
                    商品评分
                    <div class="evaluate">
                        <div class="evaluate_img shop_star">
                           
                        </div>
                        <div class="evaluate_num shop_score"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="tag_box">
        <div class="tag_title">店铺评价(<span class="shop_comment_num"></span>)</div>
        <div class="tag_main">
            <ul id="tag_ul">
<!--                 <li>
                    <div class="li_box">味道赞(92)</div>
                </li> -->
            </ul>
        </div>
    </div>
    <div class="evaluate_box">
        <ul id="comment_ul">
<!--             <li>
                <div class="li_box">
                    <div class="li_boxl">
                        <div class="li_img">
                            <img src="../image/temp/1.png">
                        </div>
                    </div>
                    <div class="li_boxr">
                        <div class="name">用户昵称</div>
                        <div class="evaluate">商品： <span class="evaluate_good">好评</span><img src="../image/evaluate_good.png"></div>
                        <div class="evaluate_content">很好吃</div>
                        <div class="goods_img_box">
                            <div class="goods_img">
                                <img src="../image/temp/1.png">
                            </div>
                            <div class="goods_img">
                                <img src="../image/temp/1.png">
                            </div>
                        </div>
                    </div>
                </div>
            </li> -->
        </ul>
        <!-- <div class="loading">loading...</div> -->
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script id="tagTpl" type="text/x-dot-template">
    {{ for(var i=0;i<it.length;i++){ }}
        <li>
            <div class="li_box">{{=it[i]['name']}}({{=it[i]['tag_num']}})</div>
        </li>
    {{ }; }}
</script>
<script id="commentTpl" type="text/x-dot-template">
    {{ for(var i=0;i<it.length;i++){ }}
        <li>
            <div class="li_box">
                <div class="li_boxl">
                    <div class="li_img">
                        <img src="{{=formatVideoImg(it[i]['img'])}}">
                    </div>
                </div>
                <div class="li_boxr">
                    <div class="name">{{=it[i]['nickname']}}</div>
                    <div class="evaluate">
                        商品： 
                        {{if(it[i]['opinion'] == 1){ }}
                            <span class="evaluate_good">好评</span><img src="../image/evaluate_good.png">
                        {{ }else{ }}
                            <span class="evaluate_bad">差评</span><img src="../image/evaluate_bad.png">

                        {{ }; }}
                    </div>
                    <div class="evaluate_content">{{=it[i]['content']}}</div>
                    {{ if(it[i]['pictures']){ }}
                        <div class="goods_img_box">
                            {{for(var j=0;j<it[i]['pictures'].length;j++){ }}
                                <div class="goods_img">
                                    <img src="{{=formatVideoImg(it[i]['pictures'][j]['img'])}}">
                                </div>
                            {{ }; }}
                        </div>
                    {{ }; }}
                </div>
            </div>
        </li>
    {{ }; }}
</script>
<script type="text/javascript">
    apiready = function(){
        id = api.pageParam.id;
        p = 1;
        canLoad = true;
        fnGetshopComment();
        fnGetComment();

                //上拉加载
        api.addEventListener({
            name:'scrolltobottom',
            extra:{
                threshold:0            //设置距离底部多少距离时触发，默认值为0，数字类型
            }
        }, function(ret, err){
            if(canLoad) {
                p++;
                if($(window).scrollTop()) {
                    $(".loading").show();
                }
                fnGetComment(2);
            }
        });
    };

    function fnGetshopComment() {
        api.ajax({
            url: rootPath+'/api/shop/comment_score',
            method: 'get',
            data: {
                values: { 
                    shop_id: id
                },
            }
        }, function(ret, err) {
            if (ret) {
                $('.score').text(ret.data.comment_score.score);
                var shop_star_img = '';
                if(ret.data.comment_score.shop_full_star > 0) {
                    for(var j=0;j<ret.data.comment_score.shop_full_star;j++) {
                        shop_star_img += '<img src="../image/evaluate_on.png">';
                    }
                }
                if(ret.data.comment_score.shop_half_star == 1) {
                    shop_star_img += '<img src="../image/evaluate_half.png">';
                }
                if(ret.data.comment_score.shop_off_star > 0) {
                    for(var j=0;j<ret.data.comment_score.shop_off_star;j++) {
                        shop_star_img += '<img src="../image/evaluate_off.png">';
                    }
                }
                //服务星星
                var service_star_img = '';
                if(ret.data.comment_score.service_full_star > 0) {
                    for(var j=0;j<ret.data.comment_score.service_full_star;j++) {
                        service_star_img += '<img src="../image/evaluate_on.png">';
                    }
                }
                if(ret.data.comment_score.service_half_star == 1) {
                    service_star_img += '<img src="../image/evaluate_half.png">';
                }
                if(ret.data.comment_score.service_off_star > 0) {
                    for(var j=0;j<ret.data.comment_score.service_off_star;j++) {
                        service_star_img += '<img src="../image/evaluate_off.png">';
                    }
                }
                $('.shop_star').html(shop_star_img);
                $('.shop_score').text(ret.data.comment_score.shop_score);
                $('.service_star').html(service_star_img);
                $('.service_score').text(ret.data.comment_score.service_score);
                $('.shop_comment_num').text(ret.data.shop_num);
                setDotData(ret.data.shop_tags,'tagTpl','tag_ul',true);

            } else {
                
            }
        });
    }

    function fnGetComment(type) {
        if(canLoad == false) {
            return;
        }
        canLoad = false;
        api.ajax({
            url: rootPath+'/api/shop/shop_comment_list',
            method: 'get',
            data: {
                values: { 
                    shop_id : id,
                    p : p
                },

            }
        }, function(ret, err) {
            if(type == 1) {
                $('#comment_ul').empty();
            }
            if (ret) {
                if(ret.status == 200) {
                    $('.without_data').hide();
                    $('.title_p').show();
                    appendDotData(ret.data,'commentTpl','comment_ul',true,false);
                }
            } else {
                api.toast({
                    msg: err.msg,
                    location : 'middle'
                });
            }
            if(type == 1) {
                // 是下拉刷新的，要收回
                api.refreshHeaderLoadDone();
            }
            if(type == 2) {
                //上拉给点假时间,好看些         
                setTimeout(function(){
                    $(".loading").hide();
                },1000);
                setTimeout(function(){
                    canLoad = true;
                },1100)
            }else {
                $('.loading').hide();
                canLoad = true;
            }
            closeLoading();
        });
    }
</script>
</html>